import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import com.taobao.stresstester.StressTestUtils;
import com.taobao.stresstester.core.StressResult;
import com.taobao.stresstester.core.StressTask;

/**
 * @Author: fei.wu
 * @Email: fei.wu@rograndec.com
 * @CreateDate: 2018/11/8
 * @Version: 1.0
 */
public class MainTest {

    private static SingleThreadExecutorTest s = new SingleThreadExecutorTest();

    private static RequestTest test = new RequestTest();

    public static void main(String[] args) throws InterruptedException {

        /**
         * StressTestUtils.test(int concurrencyLevel, int totalRequests, StressTask stressTask, int warmUpTime);
         * concurrencyLevel  总并发次数
         * totalRequests 总请求次数， 单个线程请求次数= totalRequests/concurrencyLevel
         * stressTask  并发主体
         * warmUpTime  初始绿灯测试stressTask次数
         */
        StressResult stressResult = StressTestUtils.test(1000, 2000, new StressTask() {
            int i;
            @Override
            public Object doTask() throws Exception {
                test.requestGet();
                i++;
                return null;
            }
        }, 0);
        //数据格式化
        String str = StressTestUtils.format(stressResult);

        System.out.println(str);

    }
}
